
function DropMenu(id,name,icon,disabled,clickMethod){
	this.id = id ;
	this.name = name ;
	this.icon = icon ;
	this.disabled = disabled ;
	this.clickMethod = clickMethod ;
	return this ;
}

DropMenu.prototype.getHtmlTag = function(){
	var row = new HtmlTag("tr");
	var tag = new HtmlTag("td");
	if(this.disabled){
		tag.setAttribute("class","dropmenu dp-disabled");
	}else{
		tag.setAttribute("class","dropmenu dp-blur");
		tag.setAttribute("onmouseover","this.className='dropmenu dp-focus'");
		tag.setAttribute("onmouseout","this.className='dropmenu dp-blur'");
		tag.setAttribute("onclick","hideDropMenuForcely();"+this.clickMethod);
	}
	if(this.icon != null && this.icon != ""){
		tag.setAttribute("style","background:url('"+this.icon+"') no-repeat;");
	}
	tag.addChild(this.name);
	row.addChild(tag);
	return row;
}

function SeperateLine(){
	this.id = "";
	return this ;
}

SeperateLine.prototype.getHtmlTag = function(){
	var row = new HtmlTag("tr");
	var tag = new HtmlTag("td");
	tag.setAttribute("class","dropmenu-seperator");
	return tag;
}

function showDropMenus(matrix,e){
	var tag = new HtmlTag("div");
	tag.setAttribute("id","dropmenu_00");
	tag.setAttribute("class","dropmenu-container");
	tag.setAttribute("onmouseover","lockDropMenu(this)");
	tag.setAttribute("onmouseout","hideDropMenu(this)");

	var table = new HtmlTag("table");
	table.setAttribute("class",'dropmenu-table');
	table.setAttribute("cellpadding",'0');
	table.setAttribute("cellspacing",'0');
	for(var i=0;i<matrix.length;i++){
		table.addChild(matrix[i].getHtmlTag());
	}
	
	tag.addChild(table);
	document.body.innerHTML += tag.getHtml();
	var div = document.getElementById("dropmenu_00");
	div.style.left = getPositionX(e);
	div.style.top = getPositionY(e);
	div.style.display = "block";
}


function getPositionX(event){
	var x = event.clientX - 100 ;
	return x ;
}
function getPositionY(event){
	var y = event.clientY - 10 ;
	return y ;
}

var dropMenuLock ;
var dropMenuBar ;
var dropMenuBox ;
function lockDropMenu(me){
	dropMenuLock = true ;
	return ;
}
function hideDropMenu(me){
	dropMenuLock = false ;
	dropMenuBox = me ;
	dropMenuBar = setTimeout("hideDropMenuNow()",500);
}

function hideDropMenuNow(){
	if(dropMenuLock){
		return ;
	}
	dropMenuBox.style.display = "none";
}
function hideDropMenuNow(){
	if(dropMenuLock){
		return ;
	}
	dropMenuBox.style.display = "none";
}

function hideDropMenuForcely(){
	var div = document.getElementById("dropmenu_00");
	div.style.display = "none";
}